package com.xiebishe.mylibrary.net.header

import com.xiebishe.mylibrary.common.getUA
import okhttp3.Interceptor
import okhttp3.Response
import java.util.*

class HeaderIntercepter(val map: MutableMap<String,String>) :Interceptor{
    private val ua by lazy {
        getUA()
    }
    override fun intercept(chain: Interceptor.Chain): Response {
        val builder = chain.request().newBuilder()
        builder.addHeader("LJ-COMMON", ua)
        map.keys.forEach {
            map[it]?.let { it1 -> builder.addHeader(it, it1) }
        }

        val request = builder.build()
        return chain.proceed(request)
    }


}